﻿using System;
using System.Collections.Generic;
using System.Text;
using BusinessFacade;
using PMS.Common;
using PMS.EntityQuery;
using System.Data;
using System.Data.SqlClient;

namespace EntityManage
{
    public class Sys_UserManageExt : ISys_UserHandlerExt
    {
        DataBase db = new DataBase();

        public DataTable GetUsersByOrgID(int orgId)
        {
            try
            {
                string SqlStr = " SELECT * FROM Sys_User WHERE Org_ID = @OrgID and Status = 1";
                SqlParameter[] prams = new SqlParameter[1];
                prams[0] = new SqlParameter("@OrgID", orgId);
                prams[0].Direction = System.Data.ParameterDirection.Input;

                return db.RunSqlTab(SqlStr, prams);
            }
            catch { }

            return null;
        }


        public string GetUserNameByID(int id)
        {
            string name = string.Empty;
            try
            {               
                string sqlStr = @"select * from Sys_User where ID=@ID";
                DataTable dt =db.RunSqlTab(sqlStr, new SqlParameter[] { new SqlParameter("@ID", id.ToString()) });
                if (dt != null && dt.Rows.Count > 0)
                {
                    name = dt.Rows[0]["Name"].ToString();
                }
            }
            catch { }
            return name;

        }
    }
}
